import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);
const Layout = () => import('@/views/layouts/layout.vue');// 布局组件
const Login = () => import('@/views/auth/index.vue');// 登录
const Main = () => import('@/views/index/index.vue');// 首页
const Error404 = () => import('@/views/page/404.vue');//404
//系统管理
const Config = () => import('@/views/system/config.vue');// 系统配置
const Adsense = () => import('@/views/system/adsense.vue');// 广告管理
const Partner = () => import('@/views/system/partner.vue');// 合作商家
//权限管理
const Manager = () => import('@/views/manager/index.vue');//管理人员
const Role = () => import('@/views/manager/role.vue');//角色管理
const Access = () => import('@/views/manager/access.vue');//权限管理
const Record = () => import('@/views/manager/record.vue');//登录日志
//内容管理
const ArticleCategory = () => import('@/views/article/category.vue');//推文类目
const Article = () => import('@/views/article/index.vue');//推文管理
const ArticleUpdate = () => import('@/views/article/article_update.vue');//编辑推文
const Page = () => import('@/views/article/page.vue');//单页管理
const PageUpdate = () => import('@/views/article/page_update.vue');//编辑单页
//会员管理
const User = () => import('@/views/user/index.vue');//会员管理
const UserGroups = () => import('@/views/user/groups/groups.vue');//分组列表
const Member = () => import('@/views/user/member.vue');//健康档案
const Agent = () => import('@/views/user/agent.vue');//代理管理
const Level = () => import('@/views/user/level.vue');//会员等级
const Integral = () => import('@/views/user/integral.vue');//积分记录
const Cash = () => import('@/views/user/cash/cash.vue');//提现管理

export const constantRouterMap = [
    {path: '/login', name: 'Login', component: Login, meta: {title: '登录', login: true}},
    {
        path: '/', component: Layout, redirect: '/main',
        children: [
            {path: '/main', name: 'Main', component: Main, meta: {title: '首页', show: true, 'icon': 'fa fa-home'}},
            {path: '/404', name: 'Error404', component: Error404, meta: {title: '404', show: false}},
        ],
    },
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: constantRouterMap
})

export default router;

//异步挂载的路由
//动态需要根据权限加载的路由表
//access：权限ID，show：菜单是否展示，title:页面title,icon:菜单图标
export const asyncRouterMap = [
    {
        path: '/config',
        component: Layout,
        meta: {title: '系统管理', 'icon': 'fa fa-cog'},
        children: [
            {path: '/config', name: 'Config', component: Config, meta: {title: '系统设置', show: true, access:'1300'}},
            {path: '/adsense', name: 'Adsense', component: Adsense, meta: {title: '广告管理', show: true, access:'1400'}},
            {path: '/partner', name: 'Partner', component: Partner, meta: {title: '合作商家', show: true, access:'1700'}},
        ],
    },
    {
        path: '/yd',
        component: Layout,
        meta: {title: '医单云', 'icon': 'fa fa-cog'},
        children: require('@/router/yd.js').router,
    },
    {
        path: '/article',
        component: Layout,
        meta: {title: '内容管理', 'icon': 'fa fa-file-text'},
        children: [
            {path: '/article', name: 'Article', component: Article, meta: {title: '推文管理', show: true, access:'1500'}},
            {path: '/article/update', name: 'ArticleUpdate', component: ArticleUpdate, meta: {title: '编辑推文', show: false, access:''}},
            {path: '/article/category', name: 'ArticleCategory', component: ArticleCategory, meta: {title: '推文类目', show: true, access:'1800'}},
            {path: '/page', name: 'Page', component: Page, meta: {title: '单页管理', show: true, access:'1600'}},
            {path: '/page/update', name: 'PageUpdate', component: PageUpdate, meta: {title: '编辑单页', show: false, access:''}},
        ],
    },
    // {
    //     path: '/new',
    //     component: Layout,
    //     meta: {title: '云单管理', 'icon': 'fa fa-send'},
    //     children: [
    //         {path: '/new', name: 'New', component: Main, meta: {title: '云单管理', show: true}},
    //         {path: '/new/column', name: 'NewColumn', component: Main, meta: {title: '规则管理', show: true}},
    //         {path: '/new/cate', name: 'NewCate', component: Main, meta: {title: '分组管理', show: true}},
    //     ],
    // },
    {
        path: '/new',
        component: Layout,
        meta: {title: '专家管理', 'icon': 'fa fa-medkit'},
        children: require('@/router/doctor.js').router,
    },
    {
        path: '/new',
        component: Layout,
        meta: {title: '商城管理', 'icon': 'fa fa-shopping-cart'},
        children: require('@/router/shop.js').router,
    },
    {
        path: '/user',
        component: Layout,
        meta: {title: '用户管理', 'icon': 'fa fa-user'},
        children: [
            {path: '/user', name: 'User', component: User, meta: {title: '会员管理', show: true, access:'1900'}},
            {path: '/agent', name: 'Agent', component: Agent, meta: {title: '会员代理', show: false, access:''}},
            {path: '/group', name: 'UserGroups', component: UserGroups, meta: {title: '分组列表', show: true, access:'2900'}},
            {path: '/member', name: 'Member', component: Member, meta: {title: '健康档案', show: true, access:'2900'}},
            {path: '/level', name: 'Level', component: Level, meta: {title: '会员等级', show: true, access:'2000'}},
            {path: '/integral', name: 'Integral', component: Integral, meta: {title: '积分记录', show: true, access:'2800'}},
            {path: '/cash', name: 'Cash', component: Cash, meta: {title: '提现管理', show: true, access:'2700'}},
        ],
    },
    {
        path: '/manager',
        component: Layout,
        meta: {title: '权限管理', 'icon': 'fa fa-legal'},
        children: [
            {path: '/manager', name: 'Manager', component: Manager, meta: {title: '管理人员', show: true, access:'1000'}},
            {path: '/role', name: 'Role', component: Role, meta: {title: '角色管理', show: true, access:'1100'}},
            {path: '/access', name: 'Access', component: Access, meta: {title: '角色权限', show: false, access:''}},
            {path: '/record', name: 'Record', component: Record, meta: {title: '登录日志', show: true, access:'1200'}},
        ],
    },
    {path: '*', redirect: '/error/404', name: '404', meta: {show: false},}
];
